package com.dididoctor.doctor.Activity.Usercentre.Approve;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dididoctor.doctor.Bean.Token;
import com.dididoctor.doctor.Bean.workTitleLitapal;
import com.dididoctor.doctor.MV.EduActivity;
import com.dididoctor.doctor.MV.adapter.CommonAdapter;
import com.dididoctor.doctor.MV.adapter.ViewHolder;
import com.dididoctor.doctor.R;
import com.dididoctor.doctor.Ui.TagsGridView;
import com.dididoctor.doctor.Utils.LoaderImage;
import com.dididoctor.doctor.Utils.Util;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 2.0
 * @类描述：
 * @项目名称：ddgh
 * @类名称： ApproveActivity
 * @包名称： com.dididoctor.doctor.Activity.Usercentre.Approve
 * @创建人： zhanjunjie
 * @创建时间：2016/4/23 15:38
 * @修改人：
 * @修改时间：2016/4/23 15:38
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class ApproveActivity extends EduActivity {

    private TextView mTvName, mTvIdNo, mTVHospital, mTvJob, mTvPass;
    private TagsGridView gridView;
    private ImageAdapter imageAdapter;
    private List<String> strings = new ArrayList<>();


    @Override

    public void init() {
        initview();

        initdata();
    }

    private void initdata() {
        mTvName.setText(Token.getName());
        mTvIdNo.setText(Token.getIdNo());
        mTVHospital.setText(Token.getAddress());
        if (!Util.isEmpty(Token.getWtId())) {
            workTitleLitapal workTitleLitapal = com.dididoctor.doctor.Bean.workTitleLitapal.getidHospitallitapal(Token.getWtId());
            if ( workTitleLitapal!=null){
                mTvJob.setText(workTitleLitapal.getName());
            }else{
                mTvJob.setText("");
            }

        } else {
            mTvJob.setText("");
        }

        String[] strings1 = Token.getCertificateUrl().split(",");
        for (int i = 0; i < strings1.length; i++) {
            strings.add(strings1[i]);
        }
        imageAdapter = new ImageAdapter(this, strings);
        gridView.setAdapter(imageAdapter);

        if ("2".equals(Token.getIsPass())) {
            mTvPass.setVisibility(View.VISIBLE);
        } else {
            mTvPass.setVisibility(View.GONE);
        }
    }

    private void initview() {
        setText(R.id.tv_title, "医生认证");
        mTvName = (TextView) findViewById(R.id.tv_name);
        mTvIdNo = (TextView) findViewById(R.id.et_dicardno);
        mTVHospital = (TextView) findViewById(R.id.tv_hospital);
        mTvJob = (TextView) findViewById(R.id.tv_jobtitle);
        gridView = (TagsGridView) findViewById(R.id.gv_image);
        mTvPass = (TextView) findViewById(R.id.tv_pass);

    }

    @Override
    public void onClickEvent(View view) {

    }

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_approve);
    }

    public class ImageAdapter extends CommonAdapter<String> {
        private ImageView iv_imageContent, iv_delectimg;
        private LoaderImage loaderImage;

        public ImageAdapter(Context context, List<String> datas) {
            super(context, datas, R.layout.item_gv_image);
            loaderImage = new LoaderImage(context);
        }

        @Override
        public void convert(int position, ViewHolder helper, String item) {
            iv_imageContent = helper.getView(R.id.iv_imageContent);
            iv_delectimg = helper.getView(R.id.iv_delectimg);
            iv_delectimg.setVisibility(View.GONE);
            loaderImage.load(iv_imageContent, item);
        }
    }
}
